import 'package:base_flutter/base_flutter.dart';
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:ls_work/ui/food_sample/add_food_sample_page.dart';

import '../../res/gaps.dart';
import '../../viewmodel/food_sample/food_sample_list_view_model.dart';

class FoodSampleListPage extends BaseStatefulMvvmWidget {
  @override
  State<StatefulWidget> createState() => _FoodSampleListState();
}

class _FoodSampleListState
    extends BaseMvvmListState<FoodSampleListViewModel, FoodSampleListPage> {
  @override
  Widget buildRootView(BuildContext context, Widget loadingContentWidget) {
    return Scaffold(
      appBar: AppBar(
        title: Text('食品留样'),
      ),
      body: Stack(
        children: [
          loadingContentWidget
              .setLocation(left: 0, right: 0, top: 0, bottom: 0),
          ElevatedButton(
              onPressed: () {
                Go().push(AddFoodSamplePage(isChange: true,));
              },
              style: ButtonStyle(
                  shape: WidgetStateProperty.all(StadiumBorder()),
                  minimumSize: WidgetStateProperty.all(Size.fromHeight(45))
              ),
              child: CommonText('登记样本', textColor: Colors.white))
              .setLocation(bottom: 20,right: 16,left: 16)
        ],
      ),
    );
  }



  @override
  Widget createItemWidget(int index) {
    return viewModel.contentItem(index);
  }

  @override
  FoodSampleListViewModel createViewModel() {
    return FoodSampleListViewModel(context);
  }

  @override
  Widget get separatorDivider => Container(height: 10,color: Colors.grey[100],);

  @override
  EdgeInsets get listPadding => EdgeInsets.only(bottom: 80);
}
